from django.contrib import admin
from .models import EmotionDiary, EmotionTrend, EmotionWarning


@admin.register(EmotionDiary)
class EmotionDiaryAdmin(admin.ModelAdmin):
    """情绪日记管理"""
    list_display = ['id', 'user', 'emotion_type', 'emotion_intensity', 'diary_date', 'created_at']
    list_filter = ['emotion_type', 'emotion_intensity', 'diary_date']
    search_fields = ['user__username', 'description']
    date_hierarchy = 'diary_date'
    ordering = ['-diary_date', '-created_at']


@admin.register(EmotionTrend)
class EmotionTrendAdmin(admin.ModelAdmin):
    """情绪趋势管理"""
    list_display = ['id', 'user', 'period_type', 'period_start', 'period_end', 'dominant_emotion', 'average_intensity']
    list_filter = ['period_type', 'dominant_emotion', 'period_start']
    search_fields = ['user__username']
    date_hierarchy = 'period_start'
    ordering = ['-period_start']


@admin.register(EmotionWarning)
class EmotionWarningAdmin(admin.ModelAdmin):
    """情绪预警管理"""
    list_display = ['id', 'user', 'warning_type', 'warning_level', 'is_handled', 'handled_at', 'created_at']
    list_filter = ['warning_type', 'warning_level', 'is_handled', 'created_at']
    search_fields = ['user__username', 'description']
    date_hierarchy = 'created_at'
    ordering = ['-created_at']
